package liu.com;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.event.EventListener;

@Configuration
@ComponentScan(basePackages ="liu.com")
@EnableAspectJAutoProxy
public class Service implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher applicationEventPublisher;
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }
    @EventListener({MyEvent.class})
    public void Service(MyEvent event) {
        System.out.println("处理的事件：" + event);
        System.out.println("处理事件的Source" + event.getSource());
    }
}
